package com.base.commom;

import java.util.HashMap;
import java.util.Map;

/**
 * 响应工具
 * @author chenluqiang
 * @date 2019/4/13
 */
public class ResponseUtils {

    /**
     * 成功返回结果
     * @author chenluqiang
     * @date 2019/4/13
     * @param [data]
     * @return java.util.Map<java.lang.String,java.lang.Object>
     */
    public static Map<String,Object> success(Object data){
        Map<String,Object> result = new HashMap<>();
        result.put("code",ResultCode.SUCCESS);
        result.put("data",data);
        return result;
    }
    public static Map<String,Object> success(String msg){
        Map<String,Object> result = new HashMap<>();
        result.put("code",ResultCode.SUCCESS);
        result.put("msg",msg);
        return result;
    }
    /**
     * 错误返回信息
     * @author chenluqiang
     * @date 2019/4/13
     * @param [msg]
     * @return java.util.Map<java.lang.String,java.lang.Object>
     */
    public static Map<String,Object> error(String msg,Object target){
        Map<String,Object> result = new HashMap<>();
        result.put("code",ResultCode.ERROR);
        result.put("msg",msg);
        result.put("target",target);
        return result;
    }
    public static Map<String,Object> error(String msg){
        Map<String,Object> result = new HashMap<>();
        result.put("code",ResultCode.ERROR);
        result.put("msg",msg);
        return result;
    }
	public static Map<String, Object> success(String msg, String key, String value) {
		 Map<String,Object> result = new HashMap<>();
        result.put("code",ResultCode.SUCCESS);
        result.put("msg",msg);
        result.put(key,value);
        return result;
	}
}
